package com.zmm.book.keep.controller;

import com.zmm.common.base.model.Result;
import com.zmm.util.auth.registry.annotation.AuthAnonymous;
import com.zmm.util.document.AnnotationUtil;
import com.zmm.util.document.code.controller.IdoController;
import com.zmm.util.document.register.CheckPermission;
import com.zmm.util.document.register.Interface;
import com.zmm.util.document.wjl.IdoSelfGroup;
import com.zmm.util.document.wjl.IdoSelfItem;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 900045
 * @description:
 * @name BookIdoController
 * @date By 2021-10-26 15:44:53
 */
@AuthAnonymous
@RestController
@RequestMapping("/order/ido")
public class BookIdoController extends IdoController {
	
	@Resource
	private AnnotationUtil annotation;

	@Override
	@Interface(isIgnore = true)
	@RequestMapping("/list")
	public Object list() {
		return super.list();
	}

	@Override
	@Interface(isIgnore = true)
	@RequestMapping("/{code}")
	public Object item(@PathVariable String code) {
		return super.item(code);
	}


	@RequestMapping("/list2")
	public Result list2() {
		try {
			IdoSelfGroup group = annotation.getAllAddTagAnnotationUrl("classpath*:com/zmm/book/keep/service/**/*.class", CheckPermission.class);
			
			return Result.ok().setData(group);
		} catch (Exception e) {
			return Result.error();
		}
	}

	@Interface(isIgnore = true)
	@RequestMapping("/2/{code}")
	public Object item2(@PathVariable String code) {
		try {
			IdoSelfItem idoSelfItem = annotation.initParam(code);
			return Result.ok().setData(idoSelfItem);
		} catch (Exception e) {
			return Result.error();
		}
	}
}
